package com.caigou.modules.center.adapter

import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.caigou.modules.center.R
import com.caigou.modules.center.bean.MessageItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/11/03
 */
class Message2ItemAdapter(dataset: MutableList<MessageItemBean>) : BaseQuickAdapter<MessageItemBean, BaseViewHolder>(R.layout.item_message2_list, dataset),
    LoadMoreModule {
    override fun convert(holder: BaseViewHolder, item: MessageItemBean) {

        if (item.type == 1) {
            holder.getView<ConstraintLayout>(R.id.item_message2_cl_system).visibility = View.GONE
            holder.getView<ConstraintLayout>(R.id.item_message2_cl_me).visibility = View.VISIBLE
            holder.setText(R.id.item_message2_tv_me_time, item.createTime)
            holder.setText(R.id.item_message2_tv_me_content, item.content)
        } else {
            holder.getView<ConstraintLayout>(R.id.item_message2_cl_system).visibility = View.VISIBLE
            holder.getView<ConstraintLayout>(R.id.item_message2_cl_me).visibility = View.GONE
            holder.setText(R.id.item_message2_tv_time, item.createTime)
            holder.setText(R.id.item_message2_tv_content, item.content)
        }
    }
}